rather than include this inside the applescript itself, the comments for the code are available here.
• property defaultDirectory is the directory where the URL applicationettes are saved. It is set to "" at the beginning of the script and then will be reset further down in the script.
• the prefPath is using the reserved word "preferences" to get the path to the Preferences folder on the user's hard drive -- the line below it is gluing on the filename "GetURL Template". By default the GetURL Template will be stored in the Preferences folder.
• if the GetURL Template file does not exist in the Preferences folder, the system will prompt you to find it, and then copy it to the Preferences folder.
• if the defaultDirectory does not exist (i.e. is not set by a property in a previous execution of the application) then the system will prompt to ask where the URL applets should be saved to.
•• tell Netscape
• Netscape is brought to the front, and the URL of the first window (the topmost window) is procured. It first tests to see if there is a window, if not it bails out (error -128 is the bailout)
• the setting of delimiters is so that the application strips off "Netscape:" which Netscape so graciously prepends to every title page.
•• Finder
• as above with the Netscape: being ripped off of the front, this part of code rips the last item off of the end of the path, which should be just the filename (as opposed to the full path "Macintosh HD: Foo Folder:Bar Folder:Baz File").
• If the template file already exists in the URL directory, the system will prompt you to ask if you want to copy another version of the template over. The error message is very vague and this should be cleared up in a later version. Then the file is duplicated (note the "with replacing").
• This is the check to see if the filename is too long (Mac files can be 32 chars). It checks for anything greater than 31 chars, and if so, it takes the first 31 chars and uses that as the title.
• Then comes the check to make sure the title of the window does not have a colon in it. If it does, the colon is stripped out and replaced by a space (because the colon character is the Mac delimiter for file paths/names).
• If the title already exists in the URL directory, the system will prompt to ask you if you want to replace. This error message is much less vague than the one mentioned above.
• we launch the template so that it will not run itself (if we remove this line, the application will run itself after the last line is executed).
• The last line is the whole point of the script, telling the Template to set its URL to the one being passed to it.
For Duke of URL questions, bug reports, and the like, visit our web page at http://www.kei.com/duke-of-url/ or send email to duke-of-url@kei.com